import Socket from './Socket'

const WebSocketPlugin = {}

WebSocketPlugin.install = function (Vue, options = {}) {
  let socket = new Socket(options)

  Vue.socket = Vue.prototype.$socket = {
    get status () {
      return socket.status
    },
    set status (s) {
      if (typeof s === 'number') {
        socket.status = s
      }
    },
    connect (...args) {
      socket.connect(...args)
    },
    send (msg) {
      console.log(msg)
    },
    config (key, value) {
      console.log(key, value)
      switch (key) {
        default: break
      }
    }
  }
}

export default WebSocketPlugin
